public class Offer {
    public static void main(String[] args){
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            String numberStr = Integer.toString(i);
            for (int j = 0; j < numberStr.length(); j++) {
                if (numberStr.charAt(j) == '9') {
                    count++;
                }
            }
        }
        System.out.println("数字9在1到100之间出现了 " + count + " 次。");
    }
}
